package com.cyy.demo.test.copy;

import com.cyy.demo.entity.User;
import com.google.common.collect.Lists;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.springframework.util.StreamUtils;

import java.util.*;
import java.util.stream.Collectors;

/**
 * @Author cyy
 * @Date 2020/7/15 11:14
 * @Description
 */
public class CopyList {


    /**
     * @author: wy
     * @date: 2020/7/16 20:38
     * @params: [str]
     * @return: void
     */


    @Test
    public void copyList() {
        User1 user1 = new User1("a", "a");
        User1 user2 = new User1("b", "b");
        List<User1> list = Lists.newArrayList(user1, user2);
        List<User1Info> list2 = Lists.newArrayList();
        Integer a = 0;
        System.out.println(Boolean.getBoolean("") == Boolean.getBoolean(Integer.toString(0)));
    }


    @Test
    public void distinctList() {
        User1 user1 = new User1("a", "a");
        User1 user2 = new User1("a", "b");
        User1 user3 = new User1("a", "a");
        List<User1> list = Lists.newArrayList(user1, user2, user3);

        ArrayList<User1> collect = list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(User1::getPassword))), ArrayList::new));
        System.out.println(collect);

        List<Object> objects = Collections.emptyList();
        System.out.println(CollectionUtils.isEmpty(objects));
    }


}
